package movee.zookeeper.leader.selector.controller;

import lombok.extern.slf4j.Slf4j;
import movee.zookeeper.leader.selector.cluster.ClusterInfo;
import movee.zookeeper.leader.selector.cluster.ClusterNodeStateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取集群的信息，leader，节点等
 *
 * @author movee
 */
@Slf4j
@RestController
@RequestMapping(value = "/v1", produces = "application/json")
public class ClusterAdmin {

    @Autowired
    private ClusterNodeStateService nodeStateService;

    @GetMapping(value = "/cluster/info")
    public ClusterInfo getClusterInfo() {
        return nodeStateService.info();
    }

}
